import moduleB from "./moduelB"
import myMesh from "./myMesh";
// import work from 'worker#./my.worker.js'
import work from "worker#./my.worker.js"
class testMap{
    constructor(configs){
        this.name = 'mytest';
        // this.scene = new Scene();
        // console.log(this.scene)
        console.log(THREE)
        let mymesh = new myMesh();
        console.error(mymesh)
        this.mymesh = mymesh;
        this.testWorker();
    }

    speak(){
        let b = new moduleB();
        b.speakHello();
    }

    delayOutput(){
        return new Promise(res=>{
            setTimeout(()=>{
                console.log('delay...')
                res();
            },500)
        })
    }
     async testWorker(){
         await this.delayOutput()
        // const worker = await new Worker("./worker.js" ,{
        //     type: "module"
        // })
        
        // const worker = new Worker("./worker.js" , {type:"module"})
        // const api = wrap(worker);
        // // // // console.log('before add' , worker)
        // const result =  await api.add(40,2)
        // // // alert(`Result: ${result}`)
        // console.log(result)
        
        // var myWorker = new Worker('./myworker.js')
        // // var myWorker = new MyWorker();
        // myWorker.onmessage = function (evt) {
        //     if (evt.data === 'hello') {
        //         myWorker.postMessage('hello back!');
        //     }
        // };

        // const result = await workerAPI.doMath(40 , 2)
        // console.log(result)

        // javascript-obfuscator:disable
        var w = new work();
        w.addEventListener('message', function (e) {
          console.info(e.data)
        })
        w.postMessage(4) // send the worker a message
        // javascript-obfuscator:disable
    }

}
export default testMap